//
//  PhotoBrowserViewController.m
//  OTOClient
//
//  Created by Suny on 15/4/6.
//  Copyright (c) 2015年 Suny. All rights reserved.
//

#import "PhotoBrowserViewController.h"
#import "BaseImageInfo.h"

@interface PhotoBrowserViewController ()

@end

@implementation PhotoBrowserViewController


- (void)viewDidLoad 
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (instancetype)initWithBaseImageInfo:(BaseImageInfo *)imageInfo

{
	self = [self initWithDelegate:self];
	if (self)
	{
		self.baseImageInfo = imageInfo;
		
	}
	
	return self;
}


- (void)requestDataFromNet
{
	
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - MWPhotoBrowser Delegate

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser
{
	return [_imageInfoMArray count];
}

- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
{
	BaseImageInfo *item = [_imageInfoMArray safeObjectAtIndex:index];

	MWPhoto     *photo       = nil;

	if ([item.imageUrlString hasPrefix:@"http://"])
	{
        photo = [MWPhoto photoWithURL:[NSURL URLWithString:item.imageUrlString]];
	}
    else
    {
        photo = [MWPhoto photoWithImage:[UIImage imageNamed:item.imageUrlString]];
    }


	photo.caption = item.descriptionString;
	return photo;
}


- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index
{
    BaseImageInfo *item = [_imageInfoMArray safeObjectAtIndex:index];

    MWPhoto     *photo       = nil;

    if ([item.thumbImageUrlString hasPrefix:@"http://"])
    {
        photo = [MWPhoto photoWithURL:[NSURL URLWithString:item.thumbImageUrlString]];
    }
    else
    {
        photo = [MWPhoto photoWithImage:[UIImage imageNamed:item.thumbImageUrlString]];
    }


    photo.caption = item.descriptionString;
    return photo;
}

- (void)dealloc
{
}


@end
